package cn.vcjf.weapp.api.goods.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.goods.entity.GoodsPropertyValue;
import cn.vcjf.weapp.api.goods.service.GoodsPropertyValueService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-25
 */
@Controller
@RequestMapping("/goods/goodsPropertyValue")
public class GoodsPropertyValueController {
     @Resource
     private GoodsPropertyValueService  goodsPropertyValueService;

     @RequestMapping("/addGoodsPropertyValue")
     @ResponseBody
     public TableResult addGoodsPropertyValue(GoodsPropertyValue goodsPropertyValue){
         goodsPropertyValue.preInsert();
         boolean b = goodsPropertyValueService.insert(goodsPropertyValue);
         return TableResult.Result(b);
     }

     @RequestMapping("/updateGoodsPropertyValue")
     @ResponseBody
     public TableResult updateGoodsPropertyValue(GoodsPropertyValue goodsPropertyValue){
         goodsPropertyValue.preUpdate();
        boolean b = goodsPropertyValueService.updateById(goodsPropertyValue);
         return TableResult.Result(b);
     }

     @RequestMapping("/findGoodsPropertyValueOne")
     @ResponseBody
     public TableResult findGoodsPropertyValueOne(GoodsPropertyValue goodsPropertyValue){

        EntityWrapper<GoodsPropertyValue> wrapper = new EntityWrapper<GoodsPropertyValue>();

        if(goodsPropertyValue.getId()!=null){
            wrapper.eq("id",goodsPropertyValue.getId());
        }
        //Todo

        GoodsPropertyValue result = goodsPropertyValueService.selectOne(wrapper);

		return TableResult.OKResult(result);
     }

     @RequestMapping("/findGoodsPropertyValueList")
     @ResponseBody
     public TableResult findGoodsPropertyValueList(GoodsPropertyValue goodsPropertyValue){

        EntityWrapper<GoodsPropertyValue> wrapper = new EntityWrapper<GoodsPropertyValue>();

		if(goodsPropertyValue.getId()!=null){
            wrapper.eq("id",goodsPropertyValue.getId());
        }
        //Todo

        Page<GoodsPropertyValue> page = goodsPropertyValue.getPageInfo();

        page = goodsPropertyValueService.selectPage(page,wrapper);

		return TableResult.OKResult(page);

     }

     @RequestMapping("/deleteGoodsPropertyValue")
     @ResponseBody
     public TableResult deleteGoodsPropertyValue(GoodsPropertyValue goodsPropertyValue){
        goodsPropertyValue.preUpdate();
        boolean b = goodsPropertyValueService.deleteById(goodsPropertyValue.getId());
        return TableResult.Result(b);
     }

}
